package com.czk.yygh.msm.receiver;

import com.alibaba.fastjson.JSONObject;
import com.czk.common.rabbit.constant.RabbitConstant;
import com.czk.vo.msm.MsmVo;
import com.czk.yygh.msm.service.MsmService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/11/29 23:03
 */
@Component
@RabbitListener(queues = RabbitConstant.QUEUE_MSM_ITEM)
public class MyMsmReceiver {
    @Autowired
    private MsmService msmService;

    @RabbitHandler
    public void process(String obj) {
       /* Message message=(Message)obj;
        System.out.println("MyMsmReceiver   开始发送短信了");
        byte[] body = message.getBody();
        // 转为
        String str=new String(body);
        JSONObject jsonObject = JSONObject.parseObject(str);
        MsmVo msmVo = jsonObject.toJavaObject(MsmVo.class);
        msmService.send(msmVo);*/
       msmService.send("15723315609",obj);
    }
}
